package com.imcrl.piano.utils
{
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;
	import flash.display.Sprite;

	public class SpriteUtils
	{
		public function SpriteUtils()
		{
		}
		
		/**
		 * 清理 ；
		 * @param container
		 * 
		 */		
		public static function clear(container:DisplayObjectContainer):void{
			while(container.numChildren){
				container.removeChildAt(0);
			}
			
		}
		
		/**
		 * 全部停止； 
		 * @param display
		 * 
		 */		
		public static function stopAll(display:DisplayObject):void{
			if(display is MovieClip){
				(display as MovieClip).gotoAndStop(1);
			}
			
			if(display is DisplayObjectContainer){
				var container:DisplayObjectContainer=display as DisplayObjectContainer;
				var len:int=container.numChildren;
				for(var i:int=0;i<len;i++){
					stopAll(container.getChildAt(i));
				}
			}
		}
		
		/**
		 *  
		 * @return 
		 * 
		 */		
		public static function createDisplayContainer(mouseChildren:Boolean=false):DisplayObjectContainer{
			var s:Sprite=new Sprite();
			s.mouseEnabled=false;
			s.mouseChildren=mouseChildren;
			return s;
		}
	}
}